﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class PlayerUI : MonoBehaviour,IEventListener {
    private CreatureData playerData;
    private Text Hp;
    private Text Attack;
    private Text Def;
    private Text Hpvalue;
    private Text AttackValue;
    private Text DefValue;
    private void Awake()
    {
        Hp = transform.Find("PlayerHP").GetComponent<Text>();
        Attack = transform.Find("PlayerAttack").GetComponent<Text>();
        Def = transform.Find("PlayerDefence").GetComponent<Text>();
        Hpvalue = Hp.transform.Find("HP").GetComponent<Text>();
        AttackValue = Attack.transform.Find("Attack").GetComponent<Text>();
        DefValue = Def.transform.Find("Defence").GetComponent<Text>();
        
    }
    private void Start()
    {
        EventNodeCore.GetInstance().AttachEventListener(EventDef.EnemyDie, this);
        EventNodeCore.GetInstance().AttachEventListener(-EventDef.PickSomeThing, this);

    }
    private void OnDestroy()
    {
        EventNodeCore.GetInstance().DetachEventListener(EventDef.EnemyDie, this);
        EventNodeCore.GetInstance().DetachEventListener(-EventDef.PickSomeThing, this);
    }
    public int EventPriority()
    {
        return 0;
    }
    public bool HandleEvent(int id,object param1,object param2)
    {
        if (id == EventDef.EnemyDie)
        {
            Debug.Log("Get Exp!!!");
            //playerData=PlayerManager.Instance.GetPlayerGrowData();
            //Hp.text ="HP "+playerData.HP.ToString();
            //Attack.text ="Attack "+playerData.ATK.ToString();
            //Def.text ="Def "+playerData.DEF.ToString();

        }
        if (id == -EventDef.PickSomeThing)
        {

            GameObject Item = (GameObject)param2;
            Debug.LogWarning(Item.name);
        }
        return false;
    }
}
